import { RouteConfig } from 'vue-router';

const prefix = 'tenants/:tenant?/projects/:project?/environments/:environment?';

export const workspace: RouteConfig[] = [
  {
    path: '/',
    name: 'workspace',
    component: () => import('@/layouts/Layout.vue'),
    redirect: { name: 'environment-detail' },
    children: [
      {
        path: '',
        meta: {
          header: 'routerbar.cluster.h_dashboard',
          title: 'routerbar.cluster.g_dashboard',
          icon: 'mdi-view-dashboard',
          required: ['tenant'],
        },
        component: () => import('@/layouts/Container.vue'),
        redirect: { name: 'environment-detail' },
        children: [
          // environment
          {
            path: `${prefix}/dashboard-environment`,
            name: 'environment-detail',
            component: () => import('@/views/resource/environment/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.environment_dashboard',
              icon: 'mdi-cloud',
              show: true,
              rootName: 'workspace',
              tip: 'environment',
              edge: false,
            },
          },
          {
            path: `${prefix}/:name/dashboard-edge`,
            name: 'edge-detail',
            component: () => import('@/views/resource/edge/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.edge_dashboard',
              icon: 'mdi-desktop-tower',
              show: true,
              rootName: 'workspace',
              tip: 'edge',
              edge: true,
            },
          },
        ],
      },
      {
        path: '',
        meta: {
          header: 'routerbar.cluster.h_app',
          title: 'routerbar.cluster.h_app',
          icon: 'mdi-view-grid',
          required: ['tenant'],
          edge: false,
        },
        component: () => import('@/layouts/Container.vue'),
        redirect: { name: 'app-list' },
        children: [
          // app
          {
            path: `${prefix}/apps`,
            name: 'app-list',
            component: () => import('@/views/resource/app/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.app',
              icon: 'mdi-apps',
              show: true,
              rootName: 'workspace',
              tip: 'app',
              edge: false,
            },
          },
          {
            path: `${prefix}/configs`,
            name: 'app-configer',
            component: () => import('@/views/resource/app_configer/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.app_config',
              icon: 'mdi-wrench',
              show: false,
              pluginOpenShow: true,
              rootName: 'workspace',
              tip: 'appconfig',
              dependencies: ['nacos'],
              edge: false,
            },
          },
          {
            path: `${prefix}/apps/:name`,
            name: 'app-detail',
            component: () => import('@/views/resource/app/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.app',
              icon: 'mdi-apps',
              show: false,
              rootName: 'workspace',
              tip: 'app',
              edge: false,
            },
          },
          {
            path: `${prefix}/apps/:name/deploy`,
            name: 'app-deploy',
            component: () => import('@/views/resource/deploy/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.app_deploy',
              icon: 'mdi-apps',
              show: false,
              rootName: 'workspace',
              tip: 'deploy',
              dependencies: ['argo-rollouts'],
              edge: false,
            },
          },
        ],
      },
      {
        path: '',
        meta: {
          header: 'routerbar.cluster.h_edge',
          title: 'routerbar.cluster.h_edge',
          icon: 'mdi-server',
          required: ['tenant'],
          edge: 'check',
        },
        component: () => import('@/layouts/Container.vue'),
        redirect: { name: 'edge-list' },
        children: [
          // app
          {
            path: `${prefix}/edges`,
            name: 'edge-list',
            component: () => import('@/views/resource/edge/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.edge',
              icon: 'mdi-desktop-tower',
              show: true,
              rootName: 'workspace',
              tip: 'edge',
              edge: 'check',
            },
          },
        ],
      },
      {
        path: '',
        meta: {
          header: 'routerbar.cluster.h_container',
          title: 'routerbar.cluster.g_runtime',
          icon: 'mdi-application',
          required: ['tenant'],
        },
        component: () => import('@/layouts/Container.vue'),
        redirect: { name: `workload-list` },
        children: [
          // workload
          {
            path: `${prefix}/workloads`,
            name: 'workload-list',
            component: () => import('@/views/resource/workload/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.workload',
              upToAdmin: true,
              icon: 'mdi-vector-arrange-above',
              show: true,
              rootName: 'workspace',
              tip: 'workload',
            },
          },
          {
            path: `${prefix}/workloads/:name`,
            name: 'workload-detail',
            component: () => import('@/views/resource/workload/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.workload',
              upToAdmin: true,
              icon: 'mdi-vector-arrange-above',
              show: false,
              rootName: 'workspace',
              tip: 'workload',
            },
          },
          // pod
          {
            path: `${prefix}/pods`,
            name: 'pod-list',
            component: () => import('@/views/resource/pod/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.pod',
              upToAdmin: true,
              icon: 'mdi-microsoft',
              show: true,
              rootName: 'workspace',
              tip: 'pod',
            },
          },
          {
            path: `${prefix}/pods/:name`,
            name: 'pod-detail',
            component: () => import('@/views/resource/pod/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.pod',
              upToAdmin: true,
              icon: 'mdi-microsoft',
              show: false,
              rootName: 'workspace',
              tip: 'pod',
            },
          },
          // service
          {
            path: `${prefix}/services`,
            name: 'service-list',
            component: () => import('@/views/resource/service/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.service',
              upToAdmin: true,
              icon: 'mdi-dns',
              show: true,
              rootName: 'workspace',
              tip: 'service',
            },
          },
          {
            path: `${prefix}/services/:name`,
            name: 'service-detail',
            component: () => import('@/views/resource/service/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.service',
              upToAdmin: true,
              icon: 'mdi-dns',
              show: false,
              rootName: 'workspace',
              tip: 'service',
            },
          },
          // ingress
          {
            path: `${prefix}/ingress`,
            name: 'ingress-list',
            component: () => import('@/views/resource/ingress/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.ingress',
              upToAdmin: true,
              icon: 'mdi-network',
              show: true,
              rootName: 'workspace',
              tip: 'ingress',
            },
          },
          {
            path: `${prefix}/ingress/:name`,
            name: 'ingress-detail',
            component: () => import('@/views/resource/ingress/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.ingress',
              upToAdmin: true,
              icon: 'mdi-network',
              show: false,
              rootName: 'workspace',
              tip: 'ingress',
            },
          },
          // gateway
          {
            path: `${prefix}/gateways`,
            name: 'gateway-center',
            component: () => import('@/views/resource/gateway/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.gateway',
              upToAdmin: true,
              icon: 'mdi-gate',
              show: true,
              rootName: 'workspace',
              tip: 'gateway',
              edge: false,
            },
          },
          {
            path: `${prefix}/gateways/:name`,
            name: 'gateway-detail',
            component: () => import('@/views/resource/gateway/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.gateway',
              upToAdmin: true,
              icon: 'mdi-gate',
              show: false,
              rootName: 'workspace',
              tip: 'gateway',
              edge: false,
            },
          },
        ],
      },
      {
        path: '',
        meta: {
          title: 'routerbar.cluster.g_task',
          icon: 'mdi-playlist-check',
          required: ['tenant'],
        },
        component: () => import('@/layouts/Container.vue'),
        redirect: { name: `job-list` },
        children: [
          // job
          {
            path: `${prefix}/jobs`,
            name: 'job-list',
            component: () => import('@/views/resource/job/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.job',
              upToAdmin: true,
              icon: 'mdi-repeat-once',
              show: true,
              rootName: 'workspace',
              tip: 'job',
            },
          },
          {
            path: `${prefix}/jobs/:name`,
            name: 'job-detail',
            component: () => import('@/views/resource/job/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.job',
              upToAdmin: true,
              icon: 'mdi-repeat-once',
              show: false,
              rootName: 'workspace',
              tip: 'job',
            },
          },
          // cronjob
          {
            path: `${prefix}/cronjobs`,
            name: 'cronjob-list',
            component: () => import('@/views/resource/cronjob/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.cronjob',
              upToAdmin: true,
              icon: 'mdi-calendar-clock',
              show: true,
              rootName: 'workspace',
              tip: 'cronjob',
            },
          },
          {
            path: `${prefix}/cronjobs/:name`,
            name: 'cronjob-detail',
            component: () => import('@/views/resource/cronjob/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.cronjob',
              upToAdmin: true,
              icon: 'mdi-calendar-clock',
              show: false,
              rootName: 'workspace',
              tip: 'cronjob',
            },
          },
        ],
      },
      {
        path: '',
        meta: {
          title: 'routerbar.cluster.g_config',
          icon: 'mdi-brightness-7',
          required: ['tenant'],
        },
        component: () => import('@/layouts/Container.vue'),
        redirect: { name: `configmap-list` },
        children: [
          // configmap
          {
            path: `${prefix}/configmaps`,
            name: 'configmap-list',
            component: () => import('@/views/resource/configmap/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.configmap',
              upToAdmin: true,
              icon: 'mdi-wrench',
              show: true,
              rootName: 'workspace',
              tip: 'configmap',
            },
          },
          {
            path: `${prefix}/configmaps/:name`,
            name: 'configmap-detail',
            component: () => import('@/views/resource/configmap/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.configmap',
              upToAdmin: true,
              icon: 'mdi-wrench',
              show: false,
              rootName: 'workspace',
              tip: 'configmap',
            },
          },
          // secret
          {
            path: `${prefix}/secrets`,
            name: 'secret-list',
            component: () => import('@/views/resource/secret/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.secret',
              upToAdmin: true,
              icon: 'mdi-key-variant',
              show: true,
              rootName: 'workspace',
              tip: 'secret',
            },
          },
          {
            path: `${prefix}/secrets/:name`,
            name: 'secret-detail',
            component: () => import('@/views/resource/secret/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.secret',
              upToAdmin: true,
              icon: 'mdi-key-variant',
              show: false,
              rootName: 'workspace',
              tip: 'secret',
            },
          },
          // certmanager
          {
            path: `${prefix}/certmanager`,
            name: 'certmanager',
            component: () => import('@/views/resource/certmanager/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.certmanager',
              upToAdmin: true,
              icon: 'mdi-book-open',
              show: true,
              rootName: 'workspace',
              tip: 'certmanager',
              dependencies: ['cert-manager'],
              edge: false,
            },
          },
          {
            path: `${prefix}/certmanager/:name`,
            name: 'certificate-detail',
            component: () => import('@/views/resource/certmanager/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.certmanager',
              upToAdmin: true,
              icon: 'mdi-book-open',
              show: false,
              rootName: 'workspace',
              tip: 'certmanager',
              dependencies: ['cert-manager'],
              edge: false,
            },
          },
        ],
      },
      {
        path: '',
        meta: {
          title: 'routerbar.cluster.g_storage',
          icon: 'mdi-database',
          required: ['tenant'],
        },
        component: () => import('@/layouts/Container.vue'),
        redirect: { name: `persistentvolumeclaim-list` },
        children: [
          // pvc
          {
            path: `${prefix}/persistentvolumeclaims`,
            name: 'persistentvolumeclaim-list',
            component: () => import('@/views/resource/persistentvolumeclaim/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.persistentvolumeclaim',
              upToAdmin: true,
              icon: 'mdi-database',
              show: true,
              rootName: 'workspace',
              tip: 'persistentvolumeclaim',
            },
          },
          {
            path: `${prefix}/persistentvolumeclaims/:name`,
            name: 'persistentvolumeclaim-detail',
            component: () => import('@/views/resource/persistentvolumeclaim/detail.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.persistentvolumeclaim',
              upToAdmin: true,
              icon: 'mdi-database',
              show: false,
              rootName: 'workspace',
              tip: 'persistentvolumeclaim',
            },
          },
          // volumesnapshot
          {
            path: `${prefix}/volumesnapshots`,
            name: 'volumesnapshot-list',
            component: () => import('@/views/resource/volumesnapshot/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.volumesnapshot',
              upToAdmin: true,
              icon: 'mdi-camera',
              show: true,
              rootName: 'workspace',
              tip: 'volumesnapshot',
              edge: false,
            },
          },
          // storageclass
          {
            path: `${prefix}/storageclasses`,
            name: `storageclass-center`,
            component: () => import('@/views/resource/storageclass/index.vue'),
            meta: {
              requireAuth: true,
              title: 'routerbar.cluster.storageclass',
              upToAdmin: true,
              icon: 'mdi-database',
              show: true,
              rootName: 'workspace',
              tip: 'storageclass',
              edge: true,
            },
          },
        ],
      },
    ],
  },
  {
    path: '/console',
    name: 'terminal',
    component: () => import('@/layouts/LayoutWithoutNavi.vue'),
    redirect: { name: 'terminal-viewer' },
    children: [
      // terminal
      {
        path: `${prefix}/terminal/:name`,
        name: 'terminal-viewer',
        component: () => import('@/views/resource/terminal/index.vue'),
        meta: {
          requireAuth: true,
          title: 'routerbar.cluster.terminal',
          upToAdmin: true,
        },
      },
    ],
  },
  {
    path: '/container',
    name: 'container-log',
    component: () => import('@/layouts/LayoutWithoutNavi.vue'),
    redirect: { name: 'container-log-viewer' },
    children: [
      // terminal
      {
        path: `${prefix}/log/:name`,
        name: 'container-log-viewer',
        component: () => import('@/views/resource/log/index.vue'),
        meta: {
          requireAuth: true,
          title: 'routerbar.cluster.log',
          upToAdmin: true,
        },
      },
    ],
  },
];
